<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 *  User_group Model Class
 *
 */
class  Config_model extends CI_Model
{
	var $id  ;

        var $iso2;

        var $iso3;

        var $numcode;
	
	var $vi_name  ;
	
	var $en_name  ;

        var $active;

        var $position;

        function __construct() {
            parent::__construct();
        }
        

	function update($data){
		 echo $sql = "UPDATE gtb_config
			SET ".
                        " config_value = " .  $this->db->escape($data['value']) . 
                	" WHERE code = '" .($data['code']) . "'";
		$this->db->query($sql);
		return $this->db->affected_rows();
	}


	function getAll(){
		$result = null;
		$sql = "SELECT * " .
				" FROM gtb_config " ;
		$query = $this->db->query($sql);
		$result = $query->result_array();

		return $result;
	}
        
        function getByCode($id){

		$sql = "SELECT *
				FROM gtb_config
				WHERE code = " . $this->db->escape($id);
		$query = $this->db->query($sql);
		if($result = $query->result_array()){
			return $result[0];
		}

		return null;
	}

}

// EOF

